﻿using RiderShop.Mobile.Modle;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace RiderShop.Mobile.Controllers
{
    public class WeixinJsSdkController : Controller
    {
        public ActionResult ConfigScript()
        {
            WeixinJsSdkModel model = new WeixinJsSdkModel(Request.Url.AbsoluteUri);
            return PartialView("ConfigScriptPartial", model);
        }

        public ActionResult ConfigScriptJsOnly()
        {
            WeixinJsSdkModel model = new WeixinJsSdkModel(Request.Url.AbsoluteUri);
            return PartialView("ConfigScriptJsOnlyPartial", model);
        }

        [HttpPost]
        public ActionResult ConfigScriptJson(string currentUrl)
        {
            WeixinJsSdkModel model = new WeixinJsSdkModel(currentUrl);
            string[] list = new string[]{"onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareQQ", "onMenuShareWeibo"};
            return Json(new
            {
                debug = false,
                appId = model.AppId, // 必填，公众号的唯一标识
                timestamp = model.Timestamp, // 必填，生成签名的时间戳
                nonceStr = model.NonceStr, // 必填，生成签名的随机串
                signature = model.Signature,// 必填，签名，见附录1
                jsApiList = list // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
            });
        }
    }
}
